package com.yang.designmode.ActionMode.interpreter;

// 客户端使用
public class Client {
    public static void main(String[] args) {
        // 构建表达式：x + y - 3
        Expression expr = new SubtractExpression(
            new AddExpression(new VariableExpression("x"), new VariableExpression("y")),
            new NumberExpression(3)
        );

        Context context = new Context();
        context.setVariable("x", 10);
        context.setVariable("y", 5);

        int result = expr.interpret(context);
        System.out.println("结果: " + result); // 输出 12
    }
}
